/**
 * 标签页视图组件
 */
import React, { Component } from 'react';

import UITabs from './UITabs';
import UIView from './UIView';

export default class UITabsView extends Component{
	
    constructor(props) {
        super(props);
    }
    
	componentDidMount() {
		const { innerView } = this.refs;
		const { toolbar } = innerView.refs;
		const { setToolbarState} = this.props;
		
		if(setToolbarState !== undefined && toolbar){
			setToolbarState(toolbar,innerView);
		}
		if(this.props.onLoadData !== undefined){
  			this.props.onLoadData(this);
  		}
	}
	
	 closeModal = (e) =>{
	 	const { innerView } = this.refs;
		innerView.closeModal();
	 }
	
	openModal = (cb) =>{
		const { innerView } = this.refs;
		innerView.openModal(cb);
	}
	
	render() {
		
		return (
			<UIView {...this.props} parent={this} ref="innerView">
				<UITabs
					{...this.props}
					ref={(inst) => this.tabs = inst}
					parent={this}
					tabConfigId={this.props.tabConfigId}
					tabContentMap={this.props.tabContentMap}
					onChange={this.props.onTabChange} 
					type={this.props.type} 
					tabPosition={this.props.tabPosition} 
					defaultActiveKey={this.props.defaultActiveKey}
					history={this.props.history}
					location={this.props.location}
				>
				</UITabs>
				{this.props.children}
			</UIView>
		);
	}
}